package com.sjd.storehouse.service;

import com.sjd.storehouse.entity.User;
import com.sjd.storehouse.mapper.UserMapper;
import org.springframework.stereotype.Service;
import org.springframework.util.DigestUtils;

import javax.annotation.Resource;

@Service
public class UserService {

    @Resource
    private UserMapper userMapper;

    public String login(String account, String pwd) {
        String pwdMD5 = DigestUtils.md5DigestAsHex(pwd.getBytes());  //密码明文转换成MD5
        User dbUser = userMapper.getByAccount(account);

        if (dbUser != null && pwdMD5.equals(dbUser.getPwd())) {
            return ""; //成功
        } else {
            return "登录名或密码错误";  //登录名或密码错误
        }
    }
}
